#include <my_header.h>
/*Usage:  */
int main(int argc, char *argv[]){
    ARGS_CHECK(argc,2);
    int fd = open(argv[1],O_RDWR);
    ERROR_CHECK(fd, -1,"open");

    char buf[6] = { 0 };
    ssize_t read_count;

    //利用循环读取文件内容，直到文件末尾或出错
    //read_count为0时说明读到文件末尾
    //read_count为-1时说明read出现错误
    while((read_count = read(fd,buf,sizeof(buf) - 1)) > 0){
        printf("read_count = %ld ,buf = %s\n",read_count, buf);

        memset(buf, 0, sizeof(buf));
    }
    //这一步是为了判断是不是read出错导致的循环结束
    ERROR_CHECK(fd, -1, "read");
    close(fd);
    return 0;
}


